package org.example.adapter.objadapter;

/**
 * @author
 * @description 适配类
 */
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V; //关联关系-聚合关系

    //构造器注入实例
    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    //转换过程
    @Override
    public int output5V() {
        int dstV = 0;
        if (null != voltage220V) {
            int srcV = voltage220V.output220V(); //获取被适配器者的电压
            System.out.println("使用对象适配器，进行适配~~~");
            dstV = srcV / 44;
            System.out.println("适配完成，输出电压为=" + dstV + "伏");
        }
        return dstV;
    }
}
